package com.crhms.seabow.controller;

import com.crhms.seabow.entity.Subtitle;
import com.crhms.seabow.repository.SubtitleRepository;
import com.crhms.seabow.service.SubtitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/subtitle")
public class SubtitleController {

    @Autowired
    private SubtitleService subtitleService;

    @Autowired
    private SubtitleRepository subtitleRepository;

    @GetMapping("/getSubtitle")
    public List<String> getSubtitle(String lessonId) {

        List<Subtitle> subtitles = subtitleService.getSubtitle(lessonId, 1);
        // String s = subtitles.stream().map(x ->" ["+ x.getStartTime() +"] "+ x.getContent() +"\n").collect(Collectors.joining());
        List<String> collect = subtitles.stream().map(s -> s.getContent()).collect(Collectors.toList());
        return collect;

    }
}